// ===============================================
// avatar_widget
//
// Create by Will on 9/4/2024 01:00
// Copyright @Will.All rights reserved.
// ===============================================

import 'package:flutter/material.dart';

import '../api_entity/user/entity/user_entity.dart';
import 'img_ex/img_ex.dart';

class AvatarWidget extends StatelessWidget {
  const AvatarWidget({
    super.key,
    required this.userEntity,
    this.width = double.infinity,
    this.borderWidth = 0,
    this.borderColor = Colors.white,
    this.canTouch = true,
  });

  final UserEntity userEntity;
  final double width;
  final double borderWidth;
  final Color borderColor;
  final bool canTouch;

  @override
  Widget build(BuildContext context) {
    return Container(
      width: width,
      height: width,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.all(
          Radius.circular(width / 2),
        ),
        border: Border.all(
          color: borderColor,
          width: borderWidth,
        ),
      ),
      child: ImgEx(
        url: userEntity.avatar ?? '',
        width: width - borderWidth,
        height: width - borderWidth,
        radius: (width - borderWidth) / 2,
        // onTap: () => canTouch
        //     ? Get.toNamed(
        //         AppRoutes.userInfo,
        //         parameters: <String, String>{
        //           'id': '${userEntity.id}',
        //         },
        //       )
        //     : null,
      ),
    );
  }
}
